<template>
	<view>
		<view class="member_scroll">
			<u-navbar leftText="返回" fixed="false" border="bottom">
				<view class="u-nav-slot dflex scrollLogo aic" slot="left">
					<u-icon name="arrow-left" size="24" @click="autoBack"></u-icon>
					<image :src="avatarSrc" class="w25 border_ccc" mode="scaleToFill" @click="toMemberIndex"
						:data-currentuid="topicCurrentUserId"></image>
					<text class="f14 fbold u-line-1" style="max-width: 120px;" @click="toMemberIndex"
						:data-currentuid="topicCurrentUserId">{{ userName }}</text>
					<!-- 用户自己看不见关注按钮 -->
					<view v-if="loginCheck">
						<view v-if="is_self">
							<view class="f12 fbold small_follow_button_check" @click="deleteFollower"
								v-if="is_followed">
								已关注
							</view>
							<view class="f12 fbold small_follow_button" @click="addFollower" v-else>
								关注+
							</view>
						</view>
					</view>
					<view v-else>
						<view class="f12 fbold small_follow_button" @click="gotoRegister">
							关注+
						</view>
					</view>
				</view>
			</u-navbar>
		</view>

		<view class="user_images p_relative" :style="{marginTop: customNavHeight + 'px;'}" @click="dbclikes">

			<u-swiper :list="userList" :autoplay="false" indicator radius="0" indicatorMode="line" circular
				:bgImage="'https://aikm.cn/static/article_bg.png'" :bgSize="'cover'" indicatorActiveColor="#ffd84a"
				:height="autoHeight" imgMode="aspectFit" @change="swiperChange"></u-swiper>

			<view v-show="topic_status == 0">
				<u-alert title="该内容正在审核,一般很快就会通过,不用担心." :description="alert_desc" type="warning"></u-alert>
			</view>

			<view v-if="topic_status == 2 || topic_status == 3 || topic_status == 4">
				<u-alert title="该内容因违反社区规范已被限制浏览!" :description="alert_desc" type="warning"></u-alert>
			</view>

			<view v-if="loginCheck">
				<view v-if="!is_self">
					<view class="p_absolute member_topic_more" @click="showMoreButton"
						style="top: 20px; right: 20px; z-index: 5;" :data-topicid="topicCurrentId">
						<u-icon name="more-circle" size="30" color="#fff"></u-icon>
					</view>
				</view>
			</view>

			<groupPurchase ref="groupPurchase" :merchant_id="merchant_id" :share_id="share_id" :share_type="share_type"
				:latitude="latitude" :longitude="longitude" :location_name="location_name"
				:location_detail="location_detail" :distanceText="distanceText">
			</groupPurchase>

			<likesAnimations ref="likesAnimations" :customNavHeight="customNavHeight">
			</likesAnimations>

		</view>

		<view>
			<u-line></u-line>
		</view>

		<!-- 
		<view id="topicimg">
			<image :src="cover" mode="widthFix"></image>
		</view> -->

		<view class="wrap dflex aic" v-if="location_detail" @click="openLocation"
			style="border-bottom: 1px solid #eee;">
			<image src="/static/dh.png" mode="aspectFit" class="w25"></image>
			<view class="cflex ml5 fg1">
				<view class="dflex f14 u-line-1 aic">
					<text class="main_price_bg mr5 p6" style="background: #ff0000; color: #fff;"
						v-if="isGroupDetail">查看团购套餐</text>
					<text>{{ location_name }}</text>
				</view>
				<text class="f12 u-line-1 ca3a3a3">{{ location_detail }}</text>
			</view>
			<u-icon name="arrow-right" color="#333"></u-icon>
		</view>

		<view class="wrap_nb" v-if="noTitle">
			<text class="fbold f16">{{ title }}</text>
		</view>

		<view class="wrap_nb f14" style="line-height: 25px;">
			<u-parse :selectable="true" :content="articleBody" :tagStyle="articleStyle"></u-parse>
		</view>

		<!-- <view class="article_button f12 dflex jcsb wrap_nb">	
			<view class="article_share">	
				<image @click="getShareQrimg" src="/static/zhuan.png" mode=""></image>
			</view>			
			<view class="article_message dflex aic">
				<view class="dflex aic" @click="topicUnCollection" v-if="is_collection">					
					<image src="/static/cang_h.png" class="w25"></image>
					<text>{{ fav_count }}</text>
				</view>
				<view class="dflex aic" @click="topicCollection" v-else>	
					<image src="/static/cang.png" class="w25"></image>
					<text>{{ fav_count }}</text>
				</view>
				<view class="dflex aic" @click="topicUnLike" v-if="is_like">					
					<image src="/static/zan_h.png" class="w25"></image>
					<text>{{ like_count }}</text>
				</view>
				<view class="dflex aic" @click="topicLike" v-else>	
					<image src="/static/zan.png" class="w25"></image>
					<text>{{ like_count }}</text>
				</view>
				<image src="/static/liu.png"></image>
				<text>{{ reply_count }}</text>
			</view>
		</view> -->

		<view class="wrap_nb cflex">
			<u-line></u-line>
			<text class="f16 fbold mt12">{{ reply_count }}条评论</text>
		</view>

		<reply ref="reply" @gotoRegister="gotoRegister" @toMemberIndex="toMemberIndex" @getReplyCount="getReplyCount"
			:defaultAvatarSrc="defaultAvatarSrc" :loginAvatarSrc="loginAvatarSrc" :is_self="is_self"
			:loginCheck="loginCheck" :topicCurrentUserId="topicCurrentUserId" :topicCurrentId="topicCurrentId"
			:loginUserId="loginUserId"></reply>

		<view class="all_comments wrap_ntb dflex jcc">
			<u-divider text="~End~"></u-divider>
		</view>

		<view class="article_bottom_ios dflex wrap" v-if="ios">
			<view class="article_share fg1" @click="openSendMessageBox">
				<u--input border="surround" placeholder="说点什么吧..." disabled="true" disabledColor="#ffffff"
					shape="circle" prefixIcon="chat" type="text"></u--input>
			</view>
			<view class="article_message dflex aic">
				<view class="dflex aic" @click="topicUnCollection" v-if="is_collection">
					<image src="/static/cang_h.png" class="w25"></image>
					<text>{{ fav_count }}</text>
				</view>
				<view class="dflex aic" @click="topicCollection" v-else>
					<image src="/static/cang.png" class="w25"></image>
					<text>{{ fav_count }}</text>
				</view>
				<view class="dflex aic" @click="topicUnLike" v-if="is_like">
					<image src="/static/zan_h.png" class="w25"></image>
					<text>{{ like_count }}</text>
				</view>
				<view class="dflex aic" @click="topicLike" v-else>
					<image src="/static/zan.png" class="w25"></image>
					<text>{{ like_count }}</text>
				</view>
				<image @click="getShareQrimg" src="/static/zhuan.png" class="w25"></image>
			</view>
		</view>

		<view class="article_bottom dflex wrap" v-else>
			<view class="article_share fg1" @click="openSendMessageBox">
				<u--input border="surround" placeholder="说点什么吧..." disabled="true" disabledColor="#ffffff"
					shape="circle" prefixIcon="chat" type="text"></u--input>
			</view>
			<view class="article_message dflex aic">
				<view class="dflex aic" @click="topicUnCollection" v-if="is_collection">
					<image src="/static/cang_h.png" class="w25"></image>
					<text>{{ fav_count }}</text>
				</view>
				<view class="dflex aic" @click="topicCollection" v-else>
					<image src="/static/cang.png" class="w25"></image>
					<text>{{ fav_count }}</text>
				</view>
				<view class="dflex aic" @click="topicUnLike" v-if="is_like">
					<image src="/static/zan_h.png" class="w25"></image>
					<text>{{ like_count }}</text>
				</view>
				<view class="dflex aic" @click="topicLike" v-else>
					<image src="/static/zan.png" class="w25"></image>
					<text>{{ like_count }}</text>
				</view>
				<image @click="getShareQrimg" src="/static/zhuan.png" class="w25"></image>
			</view>
		</view>

		<shareQrWeixin ref="shareQrcode" :topicCurrentId="topicCurrentId" :currentSwiperIndex="currentSwiperIndex">
		</shareQrWeixin>

		<u-action-sheet :actions="moreOption" :show="moreButton" :safeAreaInsetBottom="true" :closeOnClickOverlay="true"
			cancelText="取消" @close="moreButton = false" @select="moreSelect">
		</u-action-sheet>

		<u-modal :show="showDelete" title="删除确认" content="您确认要删除这片瞬间吗？" showCancelButton="true" @confirm="ensureDelete"
			@cancel="showDelete = false" @close="showDelete = false">
		</u-modal>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				domain: getApp().globalData.baseUrl,
				avatarSrc: '',
				loginAvatarSrc: '',
				defaultAvatarSrc: uni.getStorageSync('domain') + '/static/avatar.png',
				userList: [],
				customNavHeight: '',
				articleBody: ``,
				userName: '',
				title: '',
				//当前瞬间的发帖id
				topicCurrentUserId: '',
				//当前瞬间的id
				topicCurrentId: '',
				//当前瞬间的二次回复id
				secreplyCurrentId: '',
				animationData: {},
				//当前登录用户id
				loginUserId: '',
				articleStyle: {
					// 字符串的形式
					p: 'font-size:14px; line-height:25px',
				},
				noTitle: true,
				is_followed: false,
				is_self: false,
				share_id: '',
				share_type: 'topic',
				loginCheck: false,
				reply_count: '',
				fav_count: 0,
				is_collection: false,
				like_count: 0,
				is_like: false,
				type: 'topics',
				index: '',
				indicator: false,
				latitude: '',
				longitude: '',
				location_name: '',
				location_detail: '',
				cover: '',
				ios: '',
				autoHeight: '',
				sysWidth: '',
				sysHeight: '',
				//双击点赞
				touchNum: 0,
				//当前选中的轮播图,默认0
				currentSwiperIndex: 0,
				//轮播图动态比例
				swiperProp: '',
				moreButton: false,
				// moreOption : [
				// 	{
				// 		name : "编辑",
				// 		option : "edit"
				// 	},
				// 	{
				// 		name: "删除",
				// 		option : "delete"
				// 	}
				// ],
				moreOption: [{
						name: "删除",
						option: "delete"
					},
					{
						name: "编辑",
						option: "edit"
					}
				],
				showDelete: false,
				topic_status: -1,
				alert_desc: '',
				merchant_id: '',
				isGroupDetail: false,
				onlineCheck: false,
				user_latitude: '',
				user_longitude: '',
				distanceText: ''
			}
		},
		onReachBottom: function() {
			this.$refs.reply.formIndexReachBottom()
		},
		onLoad: function(e) {
			// console.log('article', e)
			// console.log('access_member_info', uni.getStorageSync('access_member_info'))

			switch (e.city) {
				case 'km':
					// uni.setStorageSync('domain','http://aikm.cc')
					uni.setStorageSync('domain', 'https://aikm.cn')
					break

				case 'ks':
					uni.setStorageSync('domain', 'https://ks.aikm.cn')
					break
			}
			// console.log('domain', uni.getStorageSync('domain'))

			var sys = uni.getSystemInfoSync()
			this.sysWidth = sys.screenWidth
			this.sysHeight = sys.screenHeight
			this.autoHeight = this.sysHeight * 0.62
			//缓存topic_id
			uni.setStorageSync('topic_id', e.TopicId)
			this.customNavHeight = sys.statusBarHeight + 44
			this.user_check(e)
			this.online_check()

			//获取系统版本，给ios添加底部安全间隙，但是老版本ios间隙就太大了
			let platform = uni.getSystemInfoSync().platform

			if (platform == 'ios') {
				this.ios = true
			} else if (platform == 'android') {
				this.ios = false
			}
		},
		// mounted() {
		// 	uni.createSelectorQuery().in(this).select('#topicimg').boundingClientRect(data => {
		// 		console.log(data)
		// 	}).exec()
		// },
		methods: {
			//获取当前位置
			getLocation() {
				return new Promise((reserve, reject) => { //因为获取位置是异步接口所以需要使用promise
					uni.getLocation({
						success: (res) => {
							// console.log('resresresres', res)
							this.user_latitude = res.latitude,
								this.user_longitude = res.longitude
							// console.log('this.latitude, this.longitude', this.latitude, this.longitude)
							this.distance(this.latitude, this.longitude)
						},
						fail: (err) => {
							this.distanceText = '获取位置失败，无法计算距离及时间。'
						}
					})
				})
			},
			//根据金纬度计算距离
			distance(lat1, lng1) {
				// console.log('cccccccccccccccccc')
				let lat2 = this.user_latitude;
				let lng2 = this.user_longitude;
				let rad1 = lat1 * Math.PI / 180.0;
				let rad2 = lat2 * Math.PI / 180.0;
				let a = rad1 - rad2;
				let b = lng1 * Math.PI / 180.0 - lng2 * Math.PI / 180.0;
				let s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(rad1) * Math.cos(rad2) * Math.pow(
					Math.sin(b / 2), 2)));
				// console.log('sssssssssssssss1', s)
				s = s * 6378.137;
				s = Math.round(s * 10000) / 10000;
				s = s.toString();
				// console.log('sssssssssssssss2', s)
				s = s.substring(0, s.indexOf('.') + 2);
				// console.log('sssssssssssssss3', s)
				let carSpeed = 30 //每小时30公里
				let carNeedTime = ((s / carSpeed) * 60).toFixed(0)
				this.distanceText = '据你' + s + '公里，驾车' + carNeedTime + '分钟'
			},
			showMoreButton() {
				this.moreButton = true
			},
			online_check() {
				uni.request({
					url: uni.getStorageSync('domain') + '/api/v1/system/online/check',
					method: 'get',
					header: {
						'Accept': 'application/json',
					},
					success: (res) => {
						this.onlineCheck = res.data.status
						uni.hideLoading();
					},
					fail: (res) => {}
				})
			},
			moreSelect(e) {
				if (e.option == "edit") {
					uni.showLoading({
						title: "加载中...."
					})
					uni.redirectTo({
						url: "/pages/member/postEdit?TopicId=" + this.topicCurrentId,
					})
				}
				if (e.option == "delete") {
					this.showDelete = true
				}
			},
			ensureDelete() {
				uni.showLoading({
					title: "删除中....",
					mask: true
				})
				uni.request({
					url: uni.getStorageSync('domain') + '/api/v1/topic_delete/' + this.topicCurrentId,
					method: 'DELETE',
					header: {
						'Accept': 'application/json',
						'Authorization': 'Bearer ' + uni.getStorageSync('access_member_info').access_token
					},
					success: (res) => {
						// console.log(res)
						if (res.data.status == "success") {
							uni.showToast({
								title: '删除成功',
								icon: 'success'
							})
						} else {
							uni.showToast({
								title: '删除失败',
								icon: 'error'
							})
							uni.hideLoading()
						}
						this.showDelete = false
						setTimeout(function() {
							uni.redirectTo({
								url: '/pages/member/member'
							})
						}, 1500)
					},
					fail: (res) => {}
				})
			},
			swiperChange(e) {
				this.currentSwiperIndex = e.current
			},
			//双击点赞
			dbclikes(e) {
				this.touchNum++
				setTimeout(() => {
					if (this.touchNum >= 2) {
						this.$refs.likesAnimations.likes(e)
						this.topicLike()
						// console.log('双击')
					}
					this.touchNum = 0
				}, 250)
			},
			//点赞动画
			animation_likes() {
				//创建动画
				var animation = uni.createAnimation({
					transformOrigin: "ease-in",
					duration: 700, //动画持续时间
					// timingFunction: 'linear',  //linear 全程匀速运动
					// delay:300  //延迟两秒执行动画
				})
				this.animation = animation

				animation.opacity(1).step()

				animation.scale(1.5, 1.5).step()

				animation.opacity(0).step()

				this.animationData = animation.export()
			},
			getReplyCount(count) {
				this.reply_count = count
			},
			openSendMessageBox() {
				this.$refs.reply.openSendMessage()
			},
			getShareQrimg() {
				this.$refs.shareQrcode.getQrcode()
			},
			gotoRegister() {
				//手机号登录
				uni.navigateTo({
					url: '/pages/register/register?from_topic=' + this.topicCurrentId
				})
			},
			user_check(e) {
				uni.showLoading({
					title: "加载中...."
				})
				uni.request({
					url: uni.getStorageSync('domain') + '/api/v1/user',
					method: 'get',
					header: {
						'Accept': 'application/json',
						'Authorization': 'Bearer ' + uni.getStorageSync('access_member_info').access_token
					},
					success: (res) => {
						if (res.statusCode == 401) {
							this.loginCheck = false
							this.loginAvatarSrc = this.defaultAvatarSrc
						}
						if (res.statusCode == 200 || res.statusCode == 201) {
							this.loginCheck = true
							this.loginAvatarSrc = res.data.avatar
							// console.log('11111111111111111',res.data)
							this.loginUserId = res.data.id
						}
						uni.hideLoading();
						this.getTopic(e)
					},
					fail: (res) => {}
				})
			},
			getTopic(e) {
				uni.showLoading({
					title: '加载中...',
					mask: false
				});
				uni.request({
					url: uni.getStorageSync('domain') + '/api/v1/topics/' + e.TopicId + '?include=user',
					// url: uni.getStorageSync('domain') + '/api/v1/topics/828?include=user',
					method: 'GET',
					header: {
						'Accept': 'application/json',
						'Authorization': 'Bearer ' + uni.getStorageSync('access_member_info').access_token
					},
					data: {},
					success: res => {
						this.userList = JSON.parse(res.data.images)
						// console.log('cccccccccccccccccc',this.userList)
						this.articleBody = res.data.body
						this.avatarSrc = res.data.user.avatar
						this.userName = res.data.user.name
						this.topicCurrentId = res.data.id
						this.topicCurrentUserId = res.data.user.id
						this.reply_count = res.data.reply_count
						this.cover = res.data.cover
						if (res.data.title == null) {
							this.noTitle = false
						}
						if (this.loginCheck == true) {
							// 判断是不是用户自己
							// console.log('is_self', res.data.user.id, uni.getStorageSync('access_member_info').user_base.id)
							if (res.data.user.id != uni.getStorageSync('access_member_info').user_base.id) {
								this.is_self = true
							}
						}
						this.title = res.data.title
						this.share_id = res.data.id
						this.fav_count = res.data.fav_count
						this.like_count = res.data.like_count
						this.latitude = res.data.latitude
						this.longitude = res.data.longitude
						this.location_name = res.data.location_name
						this.location_detail = res.data.location_detail
						this.topic_status = res.data.status
						this.alert_desc = res.data.alert_desc
						this.merchant_id = res.data.merchant_id
						// console.log('merchantmerchantmerchant', res)
						this.getFollowStatus()
						this.getCollectionStatus()
						this.getLikeStatus()
						this.$refs.reply.getReplies(e)
						//结算距离
						this.getLocation()
						//字节小程序定义导航栏文字
						uni.setNavigationBarTitle({
							title: this.title
						})
						if (this.merchant_id > 0 && this.onlineCheck == 1) {
							this.isGroupDetail = true
						}
						uni.hideLoading()
						//动态设置轮播图高度						
						// #ifdef MP-WEIXIN
						uni.getImageInfo({
							src: this.userList[0],
							success: res => {
								//默认图片1080
								if (res.width < 1080) {
									this.swiperProp = this.sysWidth / res.width;
								} else {
									this.swiperProp = this.sysWidth / 1080;
								}
								//如果有图片宽度不足1080
								this.autoHeight = Math.round(res.height * this.swiperProp)
								if (this.autoHeight > this.sysHeight * 0.62) {
									this.autoHeight = this.sysHeight * 0.62
								}
								// console.log(res.width)
								// console.log(res.height)
								// console.log(this.swiperProp )
								// console.log(this.autoHeight)
								// console.log(this.alert_desc)
							}
						})
						// #endif
					},
					fail: () => {},
					complete: () => {}
				});
			},
			getFollowStatus() {
				if (this.loginCheck == true) {
					uni.showLoading({
						title: '加载中...',
						mask: true
					});
					uni.request({
						url: uni.getStorageSync('domain') + '/api/v1/users/followers_status/' + this
							.topicCurrentUserId,
						method: 'GET',
						header: {
							'Accept': 'application/json',
							'Authorization': 'Bearer ' + uni.getStorageSync('access_member_info').access_token
						},
						success: (res) => {
							// console.log(res);
							if (res.data.status == 'followed') {
								this.is_followed = true
							}
							uni.hideLoading();
						},
						fail: (res) => {}
					})
				}
			},
			toMemberIndex(e) {
				var uid = e.currentTarget.dataset.currentuid;

				try {
					const value = uni.getStorageSync('access_member_info');
					if (value && uid == uni.getStorageSync('access_member_info').user_base.id) {
						uni.navigateTo({
							url: "/pages/member/member"
						})
					} else {
						uni.navigateTo({
							url: "/pages/member/memberStranger?uid=" + uid
						})
					}
				} catch (e) {
					console.log('err', e)
				}

			},
			autoBack() {
				uni.navigateBack({
					delta: 1,
					success: function(res) {
						// console.log(res);
					},
					fail: function(res) {
						uni.navigateTo({
							url: '/pages/index/index'
						})
					}
				});
			},
			addFollower() {
				if (this.loginCheck == true) {
					uni.showLoading({
						title: '加载中...',
						mask: true
					});
					uni.request({
						url: uni.getStorageSync('domain') + '/api/v1/users/followers/' + this.topicCurrentUserId,
						method: 'POST',
						header: {
							'Accept': 'application/json',
							'Authorization': 'Bearer ' + uni.getStorageSync('access_member_info').access_token
						},
						success: (res) => {
							// console.log(res);
							this.is_followed = true
							uni.hideLoading()
						},
						fail: (res) => {}
					})
				} else {
					this.gotoRegister()
				}
			},
			deleteFollower() {
				if (this.loginCheck == true) {
					uni.showLoading({
						title: '加载中...',
						mask: true
					});
					uni.request({
						url: uni.getStorageSync('domain') + '/api/v1/users/followers/' + this.topicCurrentUserId,
						method: 'DELETE',
						header: {
							'Accept': 'application/json',
							'Authorization': 'Bearer ' + uni.getStorageSync('access_member_info').access_token
						},
						success: (res) => {
							// console.log(res);
							this.is_followed = false
							uni.hideLoading()
						},
						fail: (res) => {}
					})
				} else {
					this.gotoRegister()
				}
			},
			//收藏、取消、状态
			topicCollection() {
				if (this.loginCheck == true) {
					uni.showLoading({
						title: '加载中...',
						mask: true
					});
					uni.request({
						url: uni.getStorageSync('domain') + '/api/v1/users/collections/' + this.topicCurrentId,
						method: 'POST',
						header: {
							'Accept': 'application/json',
							'Authorization': 'Bearer ' + uni.getStorageSync('access_member_info').access_token
						},
						success: (res) => {
							// console.log('res', res.data.status);
							if (res.data.status == 'done') {
								this.is_collection = true
								this.fav_count = res.data.fav_count
							}
							uni.hideLoading()
						},
						fail: (res) => {}
					})
				} else {
					this.gotoRegister()
				}
			},
			topicUnCollection() {
				if (this.loginCheck == true) {
					uni.showLoading({
						title: '加载中...',
						mask: true
					});
					uni.request({
						url: uni.getStorageSync('domain') + '/api/v1/users/collections/' + this.topicCurrentId,
						method: 'DELETE',
						header: {
							'Accept': 'application/json',
							'Authorization': 'Bearer ' + uni.getStorageSync('access_member_info').access_token
						},
						success: (res) => {
							// console.log('res', res.data.status);
							if (res.data.status == 'done') {
								this.is_collection = false
								this.fav_count = res.data.fav_count
							}
							uni.hideLoading()
						},
						fail: (res) => {}
					})
				} else {
					this.gotoRegister()
				}
			},
			getCollectionStatus() {
				if (this.loginCheck == true) {
					uni.showLoading({
						title: '加载中...',
						mask: true
					});
					uni.request({
						url: uni.getStorageSync('domain') + '/api/v1/users/collections/' + this.topicCurrentId,
						method: 'GET',
						header: {
							'Accept': 'application/json',
							'Authorization': 'Bearer ' + uni.getStorageSync('access_member_info').access_token
						},
						success: (res) => {
							// console.log('res', res.data.status);
							if (res.data.status == 'done') {
								this.is_collection = true
								this.fav_count = res.data.fav_count
							}
							uni.hideLoading()
						},
						fail: (res) => {}
					})
				} else {
					this.is_collection = false
				}
			},
			//点赞、取消、状态
			topicLike() {
				if (this.loginCheck == true) {
					// uni.showLoading({
					// 	title: '加载中...',
					// 	mask: true
					// });
					uni.request({
						url: uni.getStorageSync('domain') + '/api/v1/users/likes/' + this.topicCurrentId,
						method: 'POST',
						header: {
							'Accept': 'application/json',
							'Authorization': 'Bearer ' + uni.getStorageSync('access_member_info').access_token
						},
						success: (res) => {
							// console.log('res', res.data.status);
							if (res.data.status == 'done') {
								this.is_like = true
								this.like_count = res.data.like_count
							}
							uni.hideLoading()
						},
						fail: (res) => {}
					})
				} else {
					this.gotoRegister()
				}
			},
			topicUnLike() {
				if (this.loginCheck == true) {
					uni.showLoading({
						title: '加载中...',
						mask: true
					});
					uni.request({
						url: uni.getStorageSync('domain') + '/api/v1/users/likes/' + this.topicCurrentId,
						method: 'DELETE',
						header: {
							'Accept': 'application/json',
							'Authorization': 'Bearer ' + uni.getStorageSync('access_member_info').access_token
						},
						success: (res) => {
							// console.log('res', res.data.status);
							if (res.data.status == 'done') {
								this.is_like = false
								this.like_count = res.data.like_count
							}
							uni.hideLoading()
						},
						fail: (res) => {}
					})
				} else {
					this.gotoRegister()
				}
			},
			getLikeStatus() {
				if (this.loginCheck == true) {
					uni.showLoading({
						title: '加载中...',
						mask: true
					});
					uni.request({
						url: uni.getStorageSync('domain') + '/api/v1/users/likes/' + this.topicCurrentId,
						method: 'GET',
						header: {
							'Accept': 'application/json',
							'Authorization': 'Bearer ' + uni.getStorageSync('access_member_info').access_token
						},
						success: (res) => {
							// console.log('res', res.data.status);
							if (res.data.status == 'done') {
								this.is_like = true
								this.like_count = res.data.like_count
							}
							uni.hideLoading()
						},
						fail: (res) => {}
					})
				} else {
					this.is_collection = false
				}
			},
			openLocation() {
				if (this.merchant_id > 0 && this.onlineCheck == 1) {
					this.$refs.groupPurchase.openGroupPurchase()
				} else {
					uni.openLocation({
						latitude: Number(this.latitude),
						longitude: Number(this.longitude),
						success: (res) => {
							// console.log(res)
						}
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #fff;
	}

	.article_button image {
		width: 25px;
		height: 25px;
	}

	.article_message image {
		margin: 0 5px 0 15px;
	}

	.article_comments_avatar image {
		width: 30px;
		height: 30px;
		border-radius: 30px;
	}

	.comments_reply {
		margin-left: 40px;
	}

	.all_comments {
		padding-bottom: 85px;
	}

	.article_bottom_ios {
		position: fixed;
		bottom: 0;
		width: 100%;
		z-index: 99;
		background-color: #fff;
		border-top: 1px solid #eee;
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);
		box-sizing: border-box;
	}

	.article_bottom {
		position: fixed;
		bottom: 0;
		width: 100%;
		z-index: 99;
		background-color: #fff;
		border-top: 1px solid #eee;
		box-sizing: border-box;
		padding-bottom: 12px;
	}

	.reply_ico {
		font-size: 25px;
		margin-top: 5px;
	}

	.reply_ico text:nth-child(even) {
		margin: 0 5px;
	}

	.article_pop_comments_input {
		margin-bottom: 30px;
	}

	.tag_box text {
		background-color: #F6F6F6;
		color: #333;
		font-size: 14px;
		border: 1px solid #ccc;
		padding: 3px 7px;
		border-radius: 5px;
	}

	.member_topic_more {
		background-color: #000;
		opacity: 0.7;
		padding: 3px;
		border-radius: 30px;
	}
</style>